from django.urls import path, include
from apps.web.views import account, home, project, manage, wiki, file, setting, issues, dashboard, statistics

manage_patterns = ([
                       path('dashboard/', dashboard.dashboard, name='dashboard'),
                       path('dashboard/issues/chart/', dashboard.issues_chart, name='issues_chart'),

                       path('issues/', issues.issues, name='issues'),
                       path('issues/detail/<int:issues_id>/', issues.detail, name='issues_detail'),
                       path('issues/record/<int:issues_id>/', issues.record, name='issues_record'),
                       path('issues/change/<int:issues_id>/', issues.change, name='issues_change'),
                       path('invite/', issues.invite, name='invite_code'),

                       path('statistics/', statistics.statistics, name='statistics'),

                       path('file/', file.file_list, name='file_list'),
                       path('file/delete/', file.file_delete, name='file_delete'),
                       path('file/post/', file.file_post, name='file_post'),
                       path('file/download/<int:file_id>/', file.file_download, name='file_download'),
                       path('cos/credential/', file.cos_credential, name='cos_credential'),

                       path('wiki/', wiki.wiki, name='wiki'),
                       path('wiki/add/', wiki.wiki_add, name='wiki_add'),
                       path('wiki/catalog/', wiki.catalog, name='catalog'),
                       path('wiki/delete/<int:wiki_id>/', wiki.delete, name='delete'),
                       path('wiki/edit/<int:wiki_id>/', wiki.edit, name='edit'),
                       path('wiki/upload/', wiki.upload, name='upload'),

                       path('setting/', setting.setting, name='setting'),
                       path('setting/delete/', setting.project_delete, name='project_delete'),

                   ], 'manage')

urlpatterns = [
    path('register/', account.register, name='register'),
    path('send/sms/', account.send_sms, name='send_sms'),
    path('login/', account.login, name='login'),
    path('login/sms/', account.login_sms, name='login_sms'),
    path('login/pwd/', account.login_pwd, name='login_pwd'),
    path('img/code/', account.img_code, name='img_code'),
    path('index/', home.index, name='index'),
    path('logout/', home.logout, name='logout'),
    path('invite/join/<invite_code>/', issues.join, name='invite_join'),

    # 项目列表
    path('project/list/', project.project_list, name='project_list'),
    path('project/star/<project_type>/<project_id>', project.project_star, name='project_star'),
    path('project/unstar/<project_type>/<project_id>', project.project_unstar, name='project_unstar'),

    # 项目管理
    # manage_patterns
    path('manage/<int:project_id>/', include(manage_patterns, namespace='manage')),
]
